package com.lifeng.controller;

import org.apache.skywalking.apm.toolkit.trace.ActiveSpan;
import org.apache.skywalking.apm.toolkit.trace.TraceContext;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author:lifeng
 * @date:2020/3/28 12:32
 */
@RestController
public class DemoController {

    @RequestMapping("/demo")
    public Object demo(){
        //使当前链路报错，并且提示报错信息,监控台上可以看到错误
        ActiveSpan.error(new RuntimeException("错误信息"));
        //打印日志在 监控台上可以看到
        ActiveSpan.info("Test-Info-Msg");
        ActiveSpan.debug("test-debug-msg");

        //自定义tag
        ActiveSpan.tag("merorderno",System.currentTimeMillis()+"");

        //追踪id(很重要，可以和业务关联)
        String traceId = TraceContext.traceId();
        return traceId;
    }
}
